﻿using System;
using UnityEngine;

namespace Mirror {
    internal class DebugMy {

        static string Tag ;
        public static bool isShowNormalLog = false;
        public static bool isShowErrorLog = true;

        private static string sdkVersion = "";
        private static DateTime currentNow;
        internal static void Log(string msg, object o, bool current = false, string userTag = "", bool all = false) {
            if(all == true) {
                isShowNormalLog = true;
            }

            if ( o is true ) {

            } else {
                if ( isShowNormalLog == false && current == false ) {
                    return;
                }
            }

            currentNow = System.DateTime.Now;
            Tag = "["+ currentNow + $".{currentNow.Millisecond}]" + "[ WCQ"+ sdkVersion + " ][ FC:" + $"{Time.frameCount:D6}"+" ]  ";

            if (o == null) {
                if(Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor) {
                    Debug.Log(Tag + msg);
                } else {
                    Console.WriteLine(Tag + msg);
                }
            } else {
                if(Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor) {
                    Debug.Log(Tag + "[" + o.GetType().ToString() +$"({o.GetHashCode()})" + "]: " + msg);
                } else {
                    Console.WriteLine(Tag + "[" + o.GetType().ToString() + $"({o.GetHashCode()})" + "]: " + msg);
                }
            }

        }

        internal static void LogError(string msg, object o, string userTag = "") {
            if(isShowErrorLog == false)
                return;

            currentNow = System.DateTime.Now;
            Tag = "[" + currentNow + $".{currentNow.Millisecond}]" + "[ WCQ" + sdkVersion + " ][ FC:" + $"{Time.frameCount:D6}" + " ]  ";

            if (o == null) {
                if(Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor) {
                    Debug.LogError(Tag + msg);
                } else {
                    Console.WriteLine(Tag + msg);
                }
            } else {
                if(Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.WindowsEditor) {
                    Debug.LogError(Tag + "[" + o.GetType().ToString() + $"({o.GetHashCode()})" + "]: " + msg);
                } else {
                    Console.WriteLine(Tag + "[" + o.GetType().ToString() + $"({o.GetHashCode()})" + "]: " + msg);
                }
            }
        }
    }
}

